<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据统计</el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
        <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
        <div id="main" style="width: 750px;height:400px;"></div>
    </el-card>

  </div>
</template>

<script>
import echarts from 'echarts'

export default {
  name: '',
  data () {
    return {
        //需要合并的数据
    }
  },
  created() {},
  //页面元素已经渲染完毕
  async mounted() {
    var myChart = echarts.init(document.getElementById('main'));
    //准备数据项
    myChart.setOption({
        title: {
            text: '销售数量'
        },
        tooltip: {},
        legend: {
            data:['销量']
        },
        xAxis: {
            data: []
        },
        yAxis: {},
        series: [{
            name: '销量',
            type: 'bar',
            data: []
        }]
    })

    // 指定图表的配置项和数据
    const { data: res } = await this.$http.get('/sysservice/orderdetail/reportSell')
    if (res.code !== 2000) {
      return this.$message.error('获取柱状图数据失败！')
    }
    myChart.setOption({
      xAxis: {
        data: res.data.item
      },
      series: [{
        name: '销量',
        type: 'bar',
        barWidth: 100,
        data: res.data.sum
      }]
    })
  },
  methods: {}
}
</script>

<style scoped lang=scss>

</style>